package com.gticket.customerbackend.mapper;

import com.gticket.customerbackend.pojo.Payment;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 支付类
 */
@Repository
public interface PaymentMapper {

    /**
     * 查询所有支付方式
     */
    @Select("select * from ${database}.payment where flag=0")
    List<Payment> listPayment(Payment payment);

    /**
     * 根据影院id查询支付信息
     * @param payment
     * @return
     */
    @Select("select * from ${database}.payment where cinema_id=#{cinema_id} and flag=0 ")
    Payment getPaymentById(Payment payment);

    @Select("update ${database}.payment set  app_id=#{app_id},merchant_private_key=#{merchant_private_key},alipay_public_key=#{alipay_public_key}," +
            "notify_url=#{notify_url},return_url=#{return_url} where cinema_id=#{cinema_id}")
    void updatePayment(Payment payment);

    /**
     * 添加支付宝信息
     * @param payment
     */
    @Insert("insert into  ${database}.payment(app_id,merchant_private_key,alipay_public_key,notify_url,return_url,cinema_id) " +
            "values(#{app_id},#{merchant_private_key},#{alipay_public_key},#{notify_url},#{return_url},#{cinema_id})")
    void insertPayment(Payment payment);
}
